Page({
  /**
   * 页面初始数据
   * - categoryList：一级分类 + 二级分类（含 Vant 图标名称）
   * - activeIndex：默认激活第一个一级分类
   */
  data: {
    categoryList: [
      {
        id: 1,
        name: "爱礼精选",
        children: [
          { id: 101, name: "真情告白", iconName: "gift" },
          { id: 102, name: "浪漫求婚", iconName: "like" },
          { id: 103, name: "珍贵纪念", iconName: "star" },
          { id: 104, name: "爱意表达", iconName: "like" },
        ],
      },
      {
        id: 2,
        name: "鲜花玫瑰",
        children: [
          { id: 201, name: "经典永续", iconName: "hot" },
          { id: 202, name: "星座金典", iconName: "star" },
          { id: 203, name: "玫瑰经典", iconName: "fire" },
        ],
      },
      {
        id: 3,
        name: "永生玫瑰",
        children: [
          { id: 301, name: "玫瑰公仔", iconName: "cart" },
          { id: 302, name: "星座金典", iconName: "star" },
          { id: 303, name: "玫瑰系列", iconName: "gift" },
          { id: 304, name: "音乐系列", iconName: "music" },
          { id: 305, name: "经典永续", iconName: "coupon" },
          { id: 306, name: "玫瑰经典", iconName: "star" },
        ],
      },
      {
        id: 4,
        name: "玫瑰珠宝",
        children: [
          { id: 401, name: "星座经典", iconName: "diamond" },
          { id: 402, name: "爱锁系列", iconName: "lock" },
          { id: 403, name: "玫瑰公仔", iconName: "cart-circle" },
        ],
      },
      {
        id: 5,
        name: "香水体护",
        children: [
          { id: 501, name: "香水", iconName: "send-gift" },
          { id: 502, name: "织恋", iconName: "point-gift" },
          { id: 503, name: "沉爱", iconName: "like" },
        ],
      },
      {
        id: 6,
        name: "玫瑰家居",
        children: [
          { id: 601, name: "香氛蜡烛", iconName: "fire" },
          { id: 602, name: "香氛散香", iconName: "service" },
          { id: 603, name: "玫瑰礼品", iconName: "gift-card" },
          { id: 604, name: "香氛挂件", iconName: "bag" },
        ],
      },
      {
        id: 7,
        name: "开业花礼",
        children: [{ id: 701, name: "开业花篮", iconName: "shop" }],
      },
      {
        id: 8,
        name: "生日祝福",
        children: [{ id: 801, name: "生日花束", iconName: "send-gift" }],
      },
      {
        id: 9,
        name: "一周一花",
        children: [{ id: 901, name: "周花订阅", iconName: "gift-card" }],
      },
      {
        id: 10,
        name: "网红绿植",
        children: [
          { id: 1001, name: "多肉植物", iconName: "service" }],
      },
    ],
   activeIndex: 0 // 默认激活第一个分类
  },

  // 切换左侧激活分类：更新activeIndex
  handleActiveChange(e) {
    this.setData({ activeIndex: e.currentTarget.dataset.index });
  },

  // 页面首次加载：初始化数据（如请求后端分类）
  onLoad() {
    // 接口请求示例（真实项目替换模拟数据）
    // wx.request({
    //   url: 'https://your-api.com/api/category/list',
    //   success: res => res.data.code === 200 && this.setData({ categoryList: res.data.data })
    // });
  },
    
	// 下拉刷新：停止刷新动画
  onPullDownRefresh() {
    wx.stopPullDownRefresh();
  },

   // 自定义分享：配置分享卡片
  onShareAppMessage() {
    return {
      title: "商品分类",
      path: "/pages/category/category"
    };
  }
});